#include"room.h"

#include"test917.h"
Scene *room::createscene()
{
	return room::create();
}
bool room::init()
{
	if (!Scene::init())
	{
		return false;
	}
	Size visibleSize = Director::getInstance()->getVisibleSize();
	TableView *tableview = TableView::create(this,visibleSize);
	tableview->setDelegate(this);
	tableview->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	tableview->setPosition(0, 0);
	addChild(tableview);
	return true;
}
Size room::tableCellSizeForIndex(TableView* table, ssize_t idx)
{
	return Size(200, 100);
}
TableViewCell* room::tableCellAtIndex(TableView *table, ssize_t idx)
{
	TableViewCell *cell = table->dequeueCell();
	
	if (!cell)
	{
		cell = TableViewCell::create();
	}
	cell->removeAllChildrenWithCleanup(true);
	Sprite *background = Sprite::create("cell.png");
	background->setPosition(500, 0);
	Label *label = Label::createWithSystemFont(StringUtils::format("room%d", idx+1), "Arial", 40);
	cell->addChild(background);
	label->setAnchorPoint(Vec2(0,0));
	cell->addChild(label);
	return cell;

}
ssize_t room::numberOfCellsInTableView(TableView *table)
{
	return 5;
}
void room::tableCellTouched(TableView* table, TableViewCell* cell)
{
    	test917 *scene = (test917 *)test917::createscene();
		scene->setRoomId((int)cell->getIdx());
		Director::getInstance()->replaceScene(scene);
		
}